package cn.hhz.charging.cost.controller;

import cn.hhz.charging.common.pojo.JsonResult;
import cn.hhz.charging.common.pojo.param.ChargingProcessParam;
import cn.hhz.charging.common.pojo.vo.ChargingProcessVO;
import cn.hhz.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("cost")
@Api(tags = "计价服务")
public class CostController {

    @Autowired
    private CostService costService;


    /**
     * 计算电费
     * @param chargingProcessParam
     * @return
     */
    @ApiOperation("计算电费")
    @PostMapping("calculate")
    public JsonResult calculateCost(@RequestBody ChargingProcessParam chargingProcessParam) {
        log.debug("计算价格入参::{}",chargingProcessParam);
        ChargingProcessVO chargingProcessVO = costService.calculateCost(chargingProcessParam);
        log.debug("计算价格入参:{},出参:{}",chargingProcessParam,chargingProcessVO);
        return JsonResult.ok(chargingProcessVO);
    }
}
